package org.gourpg.entity.project;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.proxy.HibernateProxy;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * 任务进度登记实体
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "schedule_check_detail")
public class ScheduleCheckDetail {
    /**
     * 任务编号
     */
    @Id
    private Integer scheduleId;

    /**
     * 登记时间
     */
    private Timestamp checkTime;

    /**
     * 登记人
     */
    private Integer checkPersonId;

    /**
     * 任务说明
     */
    private String checkRemark;

    /**
     * 任务进度(0-100)
     */
    private Double processRate;

    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null) return false;
        Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
        Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
        if (thisEffectiveClass != oEffectiveClass) return false;
        ScheduleCheckDetail that = (ScheduleCheckDetail) o;
        return getScheduleId() != null && Objects.equals(getScheduleId(), that.getScheduleId());
    }

    @Override
    public final int hashCode() {
        return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
    }
}
